@include('Home.head')
<style>

    .el-carousel__item:nth-child(2n) {
        background-color: #99a9bf;

    }

    .el-carousel__item:nth-child(2n+1) {
        background-color: #d3dce6;
    }


    .el-carousel__item img{
        width:100%;
        height:100%;
    }

    .clothes-div
    {
        overflow:hidden;
        display: inline-block;
        margin: 5px;
    }
    .am-btn.am-btn-default.specs
    {
        float: left;
        margin-right: 3%;
        width: 65px;
        height: 40px;
        border-radius: 5px;
        color: #fff;
        background: #919891;
        text-align: center;
        margin-top: 1%;
        margin-bottom: 1%;
        outline: none;
    }
	.hearbc{
		/* border-bottom:#EE4000 2px solid; */
		background-color: #FFFFFF;
		
	}
    .specs-p
    {
        margin-top: 5%;
    }
    .am-tab-panel img{
        width: 100%;
    }
	.am-tabs-bd{
		border: none;
	}
	.op{
		color: gray;
		font-weight: 600;
		margin-top: 7px;
		padding-left: 0px;
		font-size: 12px;
		padding-right: 25px;
		border: none;
		margin-top: -4px;
	}
	
	.payment-footer {
	    display: flex;
	    align-items: center;
	    background-color: #fff;
	    padding: 0 15px;
	    height: 50px;
	    box-shadow: 0px -1px 3px rgba(0, 0, 0, 0.05);
	}
		
	.payment-footer .service-collection {
	    flex: 1;
	    display: flex;
	}
		
	.payment-footer .buy-now {
	    flex: 2;
	    color: #fff;
	    font-size: 17px;
	    text-align: center;
	    margin-left: 15px;
	}
		
	.payment-footer .buy-now {
	    flex: 2;
	    color: #fff;
	    font-size: 14px;
	    text-align: center;
	    margin-left: 15px;
	}
		
	.baoyou {
	    margin-left: 15px;
	    margin-bottom: 10px;
	    width: 48px;
	    height: 18px;
	    background: rgba(255, 229, 226, 1);
	    opacity: 1;
	    border-radius: 9px;
	    font-size: 12px;
	    text-align: center;
	    font-weight: 400;
	    line-height: 1px;
	    color: rgba(255, 0, 0, 1);
	    opacity: 1;
	}
		
	.recommend .recommend-bd ul {
	    padding: 5px 0 10px
	}
		
	.am-gallery-default > li {
	    width: 46%;
	}
		
	.recommend .recommend-bd .am-gallery-item {
	    box-shadow: 5px 10px 9px #eee;
	}
		
	.recommend .recommend-bd .am-gallery-default > li:nth-child(2n+1) {
	    padding-right: 0px !important;
	    float: left;
	    margin-left: 10px
	}
		
	.recommend .recommend-bd .am-gallery-default > li:nth-child(2n) {
	    padding-left: 0px !important;
	    float: right;
	    margin-right: 10px
	}
		
	.recommend .recommend-bd .am-gallery-item {
	    border-radius: 10px !important;
	}
	#addCarts {
	    background: -webkit-linear-gradient(left, #ffd01e, #ff8917);
	    background: linear-gradient(to right, #ffd01e, #ff8917);
	    height: 40px;
	    font-weight: 500;
	    font-size: 14px;
	    border: none;
	    border-radius: 0;
	    overflow: hidden;
	    position: relative;
	    display: inline-block;
	    box-sizing: border-box;
	    margin: 0;
	    padding: 0;
	    line-height: 1.2;
	    text-align: center;
	    -webkit-box-flex: 1;
	    -webkit-flex: 1;
	    flex: 1;
	    height: 40px;
	    font-weight: 500;
	    font-size: 14px;
	    border: none;
	    border-radius: 0;
	    margin-left: 5px;
	    border-top-left-radius: 999px;
	    border-bottom-left-radius: 999px;
	}
	#addCarts:before {
	    position: absolute;
	    top: 50%;
	    left: 50%;
	    width: 100%;
	    height: 100%;
	    background-color: #000;
	    border: inherit;
	    border-color: #000;
	    border-radius: inherit;
	    -webkit-transform: translate(-50%, -50%);
	    transform: translate(-50%, -50%);
	    opacity: 0;
	    content: ' ';
	 }
	#goCarts {
	    background: -webkit-linear-gradient(left, #ff6034, #ee0a24);
	    background: linear-gradient(to right, #ff6034, #ee0a24);
	    height: 40px;
	    font-weight: 500;
	    font-size: 14px;
	    border: none;
	    border-radius: 0;
	    overflow: hidden;
	    position: relative;
	    display: inline-block;
	    box-sizing: border-box;
	    margin: 0;
	    padding: 0;
	    line-height: 1.2;
	    text-align: center;
	    -webkit-box-flex: 1;
	    -webkit-flex: 1;
	    flex: 1;
	    height: 40px;
	    font-weight: 500;
	    font-size: 14px;
	    border: none;
	    border-radius: 0;
	    margin-right: 5px;
	    border-top-right-radius: 999px;
	    border-bottom-right-radius: 999px;
		border-top-left-radius: 999px;
		border-bottom-left-radius: 999px;
	}
	#goCarts:before {
	    position: absolute;
	    top: 50%;
	    left: 50%;
	    width: 100%;
	    height: 100%;
	    background-color: #000;
	    border: inherit;
	    border-color: #000;
	    border-radius: inherit;
	    -webkit-transform: translate(-50%, -50%);
	    transform: translate(-50%, -50%);
	    opacity: 0;
	    content: ' ';
	}
		
	.payment-footer .buy-now {
	    overflow: hidden;
	}
	.buy {
	    flex: 3;
	    margin-left: 5px;
	    display: flex;
	    color: #fff;
	}
	.payment-footer .service-collection>a img {
	    width: 20px;
	}
	
	.payment-footer .service-collection>a span {
	    line-height: 20px;
	}
	
	.payment-footer .service-collection>a {
	    flex: 1;
	    display: flex;
	    flex-direction: column;
	    align-items: center;
	    justify-content: center;
	    color: #a5a6a6;
	    font-size: 14px;
	}
	.op{
		color: red;
		font-weight: 600;
		margin-top: 7px;
		padding-left: 0px;
		font-size: 15px;
		padding-right: 25px;
		border: none;
		margin-top: -4px;
	}
</style>
</head>
<body>
<div class="container" id="app">
    <header data-am-widget="header" class="am-header am-header-default my-header hearbc">
        <div class="am-header-left am-header-nav">
            <a href="javascript:history.back(-1);" class="" style="color: #000000;">
				<i style="font-weight: 500;font-size: 18px;font-style:normal; ">返回</i>
            </a>
        </div>
        <!-- <h1 class="am-header-title">
            <a href="#title-link" class="" style="color: rgb(255,215,0);">@{{ goods.goodsname }}</a>
        </h1> -->
    </header>
    <!-- banner -->

    {{--<div class="am-slider am-slider-default" data-am-flexslider id="demo-slider-0">--}}
        {{--<ul class="am-slides">--}}
            {{--<li><img src="http://s.amazeui.org/media/i/demos/bing-1.jpg" /></li>--}}
            {{--<li><img src="http://s.amazeui.org/media/i/demos/bing-2.jpg" /></li>--}}
        {{--</ul>--}}
    {{--</div>--}}

    <template>
        <div class="block">
            <el-carousel>
                <el-carousel-item v-for="item in goodsImgName">
                  <img :src="item.img" width="100%" height="100%">
                </el-carousel-item>
            </el-carousel>
        </div>
    </template>





    <div class="gray-panel">
        <div class="paoduct-title-panel">
            <h1 class="product-h1">@{{ goods.goodsname }}</h1>
            <p><span class="am-fr product-title-gray-text">
			<!-- <i class="am-icon-star"></i>收藏 -->
			</span><span class="bold">价格：</span><span class="red2">￥@{{ goods.rulingprice }}</span>&nbsp;&nbsp;
				<span class="op" v-show="goods.is_explosive != '0.00'">PV值：@{{ goods.pk_integral }}</span>
			<span class=" textwei" style="float: right;">包邮</span>
        </div>
		</div>
        <div class="my-search-title-panel">
            <div class="my-search-title-panel" id="clothes_type" style="display: none;">
                <div class="first-each-div" v-for="v,i in specsList" >
                    <p class="my-search-titp-p am-text-sm bold specs-p">@{{ v.name }}</p>
                    <div v-for="val,index in specsLists" >
                        <div v-if = "val.specs_id == v.id"  class="you specs" >
                           <div class="clothes-div" v-for="j,m in val.vals">
                                <button type="button" class="am-btn am-btn-default specs" checkSpecs="2" v-on:click="checkedSpecs( j.id )"  :id="'specs-btnss'+j.id">@{{ j.val }}</button>    
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- <div>
                <ul class="am-avg-sm-2 am-text-center"> -->
                   <!--  <li class="am-text-center am-padding-sm" v-show="specsExist == 0 "><button type="button" class="am-btn am-btn-success am-btn-block am-radius" v-on:click="car(goods.id)">加入购物车</button></li>
                    -->
      `              <!-- <li class="am-text-center am-padding-sm"  style="width: 100%"> -->
                        <!-- <button type="button" class="am-btn am-btn-danger am-btn-block am-radius" v-on:click="add(goods.id,goods.group_id)" style="border-radius: 50px;">立即购买</button> -->
						<!-- <button type="button" class="am-btn am-btn-danger am-btn-block am-radius" v-on:click="add2()" style="border-radius: 50px;background: linear-gradient(to right, #ff6034, #ee0a24);border: none;">立即购买</button> -->
                    <!-- </li>
                </ul>
            </div> -->
        </div>
		
    <!-- 商品详情 -->
		<div data-am-widget="tabs" class="am-tabs am-tabs-d2">
		    <ul class="am-tabs-nav am-cf">
		        <li class="am-active">
		            <a href="[data-tab-panel-0]">商品详情</a>
		        </li>
		        <!-- <li class="">
		            <a href="[data-tab-panel-1]">交易记录</a>
		        </li> -->
		    </ul>
		    <div class="am-tabs-bd">
		        <div data-tab-panel-0 class="am-tab-panel am-active"  v-html="goods.spec" style="display: block"></div>
{{--		        <div data-tab-panel-1 class="am-tab-panel ">--}}
{{--		--}}
{{--		            <ul class="am-list am-list-static am-list-border am-list-striped am-text-sm">--}}
{{--		                <li v-for="val in orderData" v-if="orderData.length">@{{ val.name }}于@{{ val.createtime }}日购买成功</li>--}}
{{--		                <li v-if="orderData.length == 0">暂无交易记录</li>--}}
{{--		            </ul>--}}
{{--		--}}
{{--		        </div>--}}
		    </div>
		</div> 
		   
		   <footer data-am-widget="navbar" class="am-navbar am-cf sxy-footer payment-footer" id="" v-cloak>
		       <div class="service-collection">
		           <a href="/home/excellent/index">
		               <img src="http://qiniu.baoliy168.com/%E7%BB%84%203478%403x.png" alt="">
		               <span style="color:#333333;font-size:10px">首页</span>
		           </a>
		           <a href="tel:15882274651">
		               <img src="http://qiniu.baoliy168.com/348b20897fd30a0b6bcaa9a65ba98cb.png" alt="">
		               <span style="color:#333333;font-size:10px">客服</span>
		           </a>
		       </div>
		       <div class="buy">
		           <button id="goCarts" v-on:click="add2()" style="font-size: 16px;">立即购买</button>
		       </div>
		   </footer>
		   
    </div>
</body>
<script type="text/javascript">
    function checkedSpecs(e)
    {
        var checkSpecs = $("#specs-btnss"+e).attr( "checkSpecs" );
        if ( checkSpecs == 1 ) {
            $("#specs-btnss"+e).attr( "checkSpecs", 2 );
            $("#specs-btnss"+e).css("background","#919891");
        } else {
            $("#specs-btnss"+e).attr( "checkSpecs", 1 );
            $("#specs-btnss"+e).css("background","#5bb95b");
            $("#specs-btnss"+e).parent('.clothes-div').siblings('').find('button').attr( "checkSpecs", 2 );
            $("#specs-btnss"+e).parent('.clothes-div').siblings('').find('button').css("background","#919891");
        }
    }
</script>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            hostUrl:"http://www.baoli.com",
            goods:[],
            goodsImgName:[],
            number:1,
            MicroLeve:[],//商城等级
            user:[],//会员
            orderData:[],//交易记录
            //商品规格名
            specsList :{},
            //商品规格名--值
            specsLists:{},
            specsExist:0,
			buy_num:'',
			userinfo:[],
			group_id:'',
			userid:'',
			buy_name:'',
			type:''
        },
        //事件
        methods: {
            //初始化 系统管理员列表
            initialize:function () {
                var id = this.obtain('id');
                if(id > 0){
                    //获取商品数据
                    $.post("/home/straightShop/goods",{'_token':'{{csrf_token()}}',class:'find',id:id},function (res) {
                        if(res.code == 1){
                            app.goods = res.data.goods;
                            app.specsList = res.GoodsSpecsName;
                            app.specsLists = res.GoodsSpecsVal;
							app.buy_num =res.count;
							app.group_id = res.group_id;
                            if ( app.specsList.length != 0 ) {
                                $("#clothes_type").show();
                                app.specsExist = 1;
                            }
                            app.number = app.goods.purchase_num;
                            app.goodsImgName = res.data.goodsImgName;
                            app.user = res.data.user;
                            app.orderData = res.orderData;
                            app.MicroLeve = res.data.MicroLeve;
                        } else {
                            layer.msg(res.data);
                        }
                    });
                } else {
                    window.location.href="/home/error";
                }

            },
            numberAdd:function () { //加
                if( app.number > app.goods.total || app.number == '') {
                    layer.msg('数量不对');return;
                }
                app.number += 1;
            },
            numberMinus:function () { //减
                if(app.number <= app.goods.purchase_num || app.number == '') {
                    layer.msg('最少一件');return;
                }
                app.number -= 1;
            },
            //生成订单
			
			
			//参与人数
			add2:function(){
				var specs = '';
				window.location.href="/home/login/registerView?goodid=" + app.goods.id +"&specs=" + specs +"&level=" + app.goods.level+"&money="+app.goods.costprice;
			},
            add:function (id,group_id) {
               /*if ( id == undefined ) {
                    layer.msg("此产品正在升级中,请耐心等待,谢谢!");
                    return false;
                }*/
				var id1 = this.obtain('id');
				var gotype = '';
                var specs = '';
                var specsCheckData = [];
                if ( app.specsExist == 1 ) {
                    $(".specs-p").siblings('div').find("button").each(function(){
                        if ( $(this).attr("checkSpecs") == 1 ) {
                            specsCheckData.push( $(this).attr("checkSpecs") );
                        }
                    });
                    if ( app.specsList.length != specsCheckData.length ) {
                        layer.msg('请完整选择产品规格!');return false;
                    }
                    $(".clothes-div button").each(function(){
                        if ( $(this).attr("checkSpecs") == 1 ) {
                            var specsName = $(this).parents('.first-each-div').children('p').html();
                            var specsVal = $(this).html();
                            specs = specs+specsName+':'+specsVal+';';
                        }
                    });
                    if ( specs == '' ) {
                        layer.msg('请选择产品规格');return false;
                    }
                }
                app.number = parseInt(app.number);
                if(app.number < app.goods.purchase_num || app.number > app.goods.total || app.number == ''){
                    layer.msg('请输入正确的数量');
                    return;
                }
                layer.load(2);
                $.post("/home/microShop/microorder",{
                    '_token':'{{csrf_token()}}',
                    class:'add',
                    type:0,
                    specsExist:app.specsExist,
                    specslength:app.specsList.length,
                    Checklength:specsCheckData.length,
					group_id:group_id,
					gotype : 1,
                    goods:[
                        {
                            goodsid:id,
                            number:app.number,
                            specs:specs,
                            id:''
                        }
                    ]
                },function (res) {
                    layer.closeAll('loading');
                    if(res.code == 1){
                        layer.msg(res.data.data);
                        window.location.href="/home/orderpage?id="+res.data.id+"&gotype="+1+"&id1="+id1;
                    } else if(res.code == 0) {
                        layer.msg(res.data);
						window.location.href="/home/microShop/productmicro?id="+id1;
                    }
                });
            },
			
			
            car:function (id) {
                console.log(id)
                /* if ( id == undefined ) {
                    layer.msg("此产品正在升级中,请耐心等待,谢谢!");
                    return false;
                }*/

                var specs = '';
                var specsCheckData = [];
                if ( app.specsExist == 1 ) {
                    $(".specs-p").siblings('div').find("button").each(function(){
                        if ( $(this).attr("checkSpecs") == 1 ) {
                            specsCheckData.push( $(this).attr("checkSpecs") );
                        }
                    });
                    if ( app.specsList.length != specsCheckData.length ) {
                        layer.msg('请完整选择产品规格!');return false;
                    }
                    $(".clothes-div button").each(function(){
                        if ( $(this).attr("checkSpecs") == 1 ) {
                            var specsName = $(this).parents('.first-each-div').children('p').html();
                            var specsVal = $(this).html();
                            specs = specs+specsName+':'+specsVal+';';
                        }
                    });
                    if ( specs == '' ) {
                        layer.msg('请选择产品规格');return false;
                    }
                }
                if(app.number < app.goods.purchase_num || app.number > app.goods.total || app.number == '' || isNaN(parseInt(app.number))){
                    layer.msg('请输入正确的数量');
                    return;
                }
                $.post("/home/microShop/car", {
                    '_token': '{{csrf_token()}}',
                    class:'add',
                    goodsid:id,
                    number:app.number,
                    specs:specs,
                    specsExist:app.specsExist,
                    specslength:app.specsList.length,
                    Checklength:specsCheckData.length
                }, function (res) {
                    if (res.code) {
                        layer.msg(res.data);
                    } else {
                        layer.msg(res.data);
                    }
                });
            },
			
			pin:function(group_id){
			var id = this.obtain('id');
			var specs = '';
			var specsCheckData = [];
			if ( app.specsExist == 1 ) {
			    $(".specs-p").siblings('div').find("button").each(function(){
			        if ( $(this).attr("checkSpecs") == 1 ) {
			            specsCheckData.push( $(this).attr("checkSpecs") );
			        }
			    });
			    if ( app.specsList.length != specsCheckData.length ) {
			        layer.msg('请完整选择产品规格!');return false;
			    }
			    $(".clothes-div button").each(function(){
			        if ( $(this).attr("checkSpecs") == 1 ) {
			            var specsName = $(this).parents('.first-each-div').children('p').html();
			            var specsVal = $(this).html();
			            specs = specs+specsName+':'+specsVal+';';
			        }
			    });
			    if ( specs == '' ) {
			        layer.msg('请选择产品规格');return false;
			    }
			}
			$.post("/home/straightShop/goods", {'_token': '{{csrf_token()}}',class:'group_list',
			group_id:group_id,
			goods:[
			    {
			        goodsid:id,
			        number:app.number,
			        specs:specs,
			        id:''
			    }
			]
			}, function (res) {
					 if(res.code == 1){
						 app.userinfo = res.data;
					 }else if(res.code == 0){
						 layer.msg(res.data)
						 window.location.href="/home/microShop/productmicro?id="+id;
					 }
				});
			},
			
            //获取url id
            obtain:function (val) {
                var query = window.location.search.substring(1);
                var vars = query.split("&");
                for (var i=0;i<vars.length;i++) {
                    var pair = vars[i].split("=");
                    if(pair[0] == val){
                        return pair[1];
                    }
                }
            },
        },
        //自动执行
        mounted: function () {
            this.initialize();
        },
    });
</script>
</html>
